package com.bean.other;

import com.bean.base.TokenInfo;
import lombok.Data;

@Data
public class ResponseData<Obj> {

    private int code;
    private String state;
    private String message;
    private Obj obj;
    private MetaInfo metaInfo;
    private String token;
    private TokenInfo tokenInfo;

    public static ResponseData<Object> success(String message){
        ResponseData<Object> responseData=new ResponseData<>();
        responseData.setCode(200);
        responseData.setState("success");
        responseData.setMessage(message);
        return responseData;
    }

    public static ResponseData<Object> success(Object object){
        ResponseData<Object> responseData=new ResponseData<>();
        responseData.setCode(200);
        responseData.setState("success");
        responseData.setObj(object);
        return responseData;
    }

    public static ResponseData<Object> success(Object object,MetaInfo metaInfo){
        ResponseData<Object> responseData=new ResponseData<>();
        responseData.setCode(200);
        responseData.setState("success");
        responseData.setObj(object);
        responseData.setMetaInfo(metaInfo);
        return responseData;
    }

    public static ResponseData<Object> success(String message,String token,TokenInfo tokenInfo){
        ResponseData<Object> responseData=new ResponseData<>();
        responseData.setCode(200);
        responseData.setState("success");
        responseData.setMessage(message);
        responseData.setToken(token);
        responseData.setTokenInfo(tokenInfo);
        return responseData;
    }

    public static ResponseData<Object> error(String message){
        ResponseData<Object> responseData=new ResponseData<>();
        responseData.setCode(200);
        responseData.setState("error");
        responseData.setMessage(message);
        return responseData;
    }

}
